$(function(){
    var number = $('.detailListImgBox li').length;
    var allWidth = number*260;
    $('.detailListImgBox ul').width(allWidth);

    if(number>3){
        $('.buttonSlider').show();
        slide();
    }else{
        $('.buttonSlider').hide();
    }

    function slide(){
        var onceslide = 780;
        var slideWidth = 0; //滚动宽度

        $('.goRight').on('click',function(){
            if(slideWidth<allWidth-onceslide*2){
                slideWidth+=onceslide;
            }else{
                slideWidth=allWidth-onceslide;
            }
            $('.detailListImgBox ul').animate({ marginLeft: '-'+slideWidth },500);
        });

        $('.goLeft').on('click',function(){
            if(slideWidth>onceslide){
                slideWidth-=onceslide;
            }else{
                slideWidth=0;
            }
            $('.detailListImgBox ul').animate({ marginLeft: '-'+slideWidth },500);
        })
    }
});